package com.bus.controller;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bus.entity.Categorys;
import com.bus.service.CategoryService;
import com.bus.util.Page;
import com.bus.util.ResultMap;

@Controller
public class CategoryController {
    @Autowired
    private CategoryService cs;

    @RequestMapping("/category_select.action")
    public String CategorySearchByPage() {
        return "admin/category/categorySearch.jsp";
    }

    @RequestMapping("/doCategorySearchByPage.action")

    public @ResponseBody
    ResultMap<List<Categorys>> doSearchByPage(Page page, @RequestParam("limit") int limit) throws IOException {
        page.setRows(limit);
        Integer count = cs.findCountCate();
        List<Categorys> list = cs.findCateByPage(page);
        for (Categorys c : list) {
            System.err.println(c);
        }
        System.out.println(page + "---" + limit);
        page.setTotalRecord(count);

        // mav.setViewName("admin/category/categorySearch.jsp");
        return new ResultMap<List<Categorys>>("", list, 0, count);
    }

}
